--
-- Author: dbliu
-- Date: 2014-02-27 09:34:22
--


local EM = import("..EM")
local EMProp = class("EMProp", EM)


-- 定义事件
EMProp.START_EVENT = "START_EVENT"
EMProp.KILL_EVENT = "KILL_EVENT"
EMProp.FALL_EVENT = "FALL_EVENT"

EMProp.schema = clone(EM.schema)

function EMProp:ctor(EMProperties, events, callbacks)

	local defaultEvents = {
		--掉落过程
		{name = "fall", from = "idle",    to = "falling"},
	}

	-- 如果继承类提供了其他事件，则合并
	table.insertTo(defaultEvents, totable(events))

	-- 设计状态机的默认回调
	local defaultCallbacks = {
		onfall = handler(self, self.onFall),
	}

	-- 如果继承类提供了其他回调，则合并
	table.merge(defaultCallbacks,totable(callbacks))

	EMProp.super.ctor(self,EMProperties, defaultEvents, defaultCallbacks)
end


function EMProp:onFall( event )
	print("function EMProp:onFall( event )")
	print("event.from="..event.from)
	event = {name = EMProp.FALL_EVENT, from = event.from, to = event.to ,id=self:getId() }
    self:dispatchEvent(event)
end


return EMProp